﻿@{
    Layout = "~/Views/Shared/ShouYe.cshtml";
}
@using Webdiyer.WebControls.Mvc;
@model PagedList<UI.ServiceReference1.Staff>
<!DOCTYPE html>
<script src="~/BootstrapSouce/js/jquery.min.js"></script>
<link href="~/BootstrapSouce/css/bootstrap.min.css" rel="stylesheet" />
<script src="~/BootstrapSouce/js/bootstrap.min.js"></script>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Renyuandangan</title>
</head>
<body >

        <a data-target="#Add" data-toggle="modal" href="#" onclick="Add"><input type="button" value="添加人员信息" class="btn" style="color: rgb(212, 106, 64);"></a>
   

    <div>
       
        <br />
        <table class="table table-bordered table-hover definewidth m10">
            <tr>
                <td>编号</td>
                <td>姓名</td>
                <td>年龄</td>
                <td>性别</td>
                <td>住址</td>
                <td>基本工资</td>
                <td>工龄</td>
                <td>入职时间</td>
                <td>是否培训</td>
                <td>所在部门</td>
                <td>是否在职</td>
                <td>技能特长</td>
                <td>本人照片</td>
                <td>操作</td>

            </tr>
            @foreach (var item in Model)
            {
                <tr>
                    <td>@item.Staff_ID</td>
                    <td><a href="/XBK/JianL/@item.Staff_ID">@item.Staff_Name</a></td>
                    <td>@item.Staff_Age</td>
                    <td>@(item.Staff_Sex == 1 ? "女" : "男")</td>
                    <td>@item.Staff_Address</td>
                    <td>@item.Staff_Money</td>
                    <td>@item.Staff_GL</td>
                    <td>@item.Hiredate</td>
                    <td>@(item.Train == 1 ? "否" : "是")</td>
                    <td>@item.BuMen</td>
                    <td>@(item.RenyuanZT == 1 ? "否" : "是")</td>
                    <td>@item.JishuTechang</td>
                    <td><img src="@item.Image_Url" style="height:80px;width:80px" /></td>
                    <td style="display:none">@item.Image_Url</td>
                    <td><a data-target="#update" data-toggle="modal" href="#" onclick="update(this)"><input type="button" value="修改" class="btn btn-primary"></a></td>
                </tr>
            }
        </table>
        <div>@Html.Pager(Model, new PagerOptions { PageIndexParameterName = "PageIndx" })</div>
    </div>
    
    <div class="modal fade" id="Add" aria-hidden="true" style="font-size: 12px; line-height: 1.5; color:#000000" >
        <div class="modal-dialog" style="height:500px;width:500px;left:100px">
            <div class="modal-content" style="background-color:rgb(128, 128, 128)">
                <button type="button" class="close" data-dissmiss="modal">
                    ×
                </button>
                <h4>
                    添加人员信息
                </h4>

                <form action="/XBK/RenAdd" enctype="multipart/form-data" method="post">
                    <div class="modal-body">

                        <table class="table table-bordered ">
                            <tr><td>姓名</td><td><input id="Staff_Name" type="text" name="Staff_Name" /></td></tr>
                            <tr><td>年龄</td><td><input id="Staff_Age" type="text" name="Staff_Age" /></td></tr>
                            <tr><td>性别</td><td><input id="Radio1" type="radio" name="Staff_Sex" value="0" checked="checked" />男<input id="Radio1" type="radio" name="Staff_Sex" value="1" />女</td></tr>
                            <tr><td>住址</td><td><input id="Staff_Address" type="text" name="Staff_Address" /></td></tr>
                            <tr><td>基本工资</td><td><input id="Staff_Money" type="text" name="Staff_Money" /></td></tr>
                            <tr><td>工龄</td><td><input id="Staff_GL" type="text" name="Staff_GL" /></td></tr>
                            <tr><td>入职时间</td><td><input id="Hiredate" type="text" name="Hiredate" /></td></tr>
                            <tr><td>是否培训</td><td><input id="Train" type="radio" name="Train" value="0" checked="checked" />是<input id="Train" type="radio" name="Train" value="1" />否</td></tr>
                            <tr><td>所在部门</td><td><select name="BuMen"><option value="技术部">技术部</option><option value="市场部">市场部</option><option value="前台">前台</option><option value="销售部">销售部</option></select></td></tr>
                            <tr><td>是否在职</td><td><input id="RenyuanZT" type="radio" name="RenyuanZT" value="0" checked="checked" />是<input id="RenyuanZT" type="radio" name="RenyuanZT" value="1" />否</td></tr>
                            <tr><td>技术特长</td><td><input id="JishuTechang" type="text" name="JishuTechang" /></td></tr>
                            <tr><td>本人照片：</td><td><input type="file" id="f" name="Image_Url" accept="image/jpeg" onchange="show()" /><span><img id="img" src="" width="60" height="60" /></span></td></tr>
                        </table>

                    </div>
                    <div class="modal-footer">
                        <input id="Button1" type="button" value="点击任一处关闭" />
                        <input id="Button1" type="submit" value="提交更改" />
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="modal fade" id="update" aria-hidden="true" style="font-size: 12px; line-height: 1.5; color:#000000">
        <div class="modal-dialog" style="height:500px;width:500px;left:100px">
            <div class="modal-content" style="background-color:rgb(128, 128, 128)">
                <button type="button" class="close" data-dissmiss="modal">
                    ×
                </button>
                <h4>
                    修改人员信息
                </h4>

                <form action="/XBK/RenUpdae" enctype="multipart/form-data" method="post">
                    <div class="modal-body">

                        <table class ="table table-bordered ">
                            <tr><td></td><td><input id="Staff_ID" type="hidden" name="Staff_ID" /></td></tr>
                            <tr><td>姓名</td><td><input id="Name" type="text" name="Staff_Name" /></td></tr>
                            <tr><td>年龄</td><td><input id="Age" type="text" name="Staff_Age" /></td></tr>
                            <tr><td>性别</td><td><input id="Radio" type="radio" name="Staff_Sex" value="0" checked="checked" />男<input id="Radio" type="radio" name="Staff_Sex" value="1" />女</td></tr>
                            <tr><td>住址</td><td><input id="Address" type="text" name="Staff_Address" /></td></tr>
                            <tr><td>基本工资</td><td><input id="Money" type="text" name="Staff_Money" /></td></tr>
                            <tr><td>工龄</td><td><input id="GL" type="text" name="Staff_GL" /></td></tr>
                            <tr><td>入职时间</td><td><input id="Hiredat" type="text" name="Hiredate" /></td></tr>
                            <tr><td>是否培训</td><td><input id="Trai" type="radio" name="Train" value="0" checked="checked" />是<input id="Train" type="radio" name="Train" value="1" />否</td></tr>
                            <tr><td>所在部门</td><td><select name="BuMen"><option value="技术部">技术部</option><option value="市场部">市场部</option><option value="前台">前台</option><option value="销售部">销售部</option></select></td></tr>
                            <tr><td>是否在职</td><td><input id="RenyuanZ" type="radio" name="RenyuanZT" value="0" checked="checked" />是<input id="RenyuanZT" type="radio" name="RenyuanZT" value="1" />否</td></tr>
                            <tr><td>技术特长</td><td><input id="JishuTechan" type="text" name="JishuTechang" /></td></tr>
                            <tr><td>本人照片：</td><td><input type="file" id="f1" name="Image_Url1" accept="image/jpeg" onchange="show1()" /><span><img id="img1" src="" width="60" height="60" /></span></td></tr>

                        </table >

                    </div>
                    <div class="modal-footer">
                        <input id="Button1" type="button" value="点击任一处关闭" />
                        <input id="Button1" type="submit" value="提交更改" />
                    </div>
                </form>
            </div>
        </div>
    </div>
    
</body>
</html>
<script>
    function show() {

        var file = document.getElementById("f").files[0];

        var fileReader = new FileReader();

        fileReader.readAsDataURL(file);

        fileReader.onload = function () {

            document.getElementById("img").src = fileReader.result;

        }

    }
    function update(obj) {
        var tds = $(obj).parent().parent().find('td');
        $("#Staff_ID").val(tds.eq(0).text());
        $("#Name").val(tds.eq(1).text());
        $("#Age").val(tds.eq(2).text());
        $("#Radio").val(tds.eq(3).text());
        $("#Address").val(tds.eq(4).text());
        $("#Money").val(tds.eq(5).text());
        $("#GL").val(tds.eq(6).text());
        $("#Hiredat").val(tds.eq(7).text());
        $("#Trai").val(tds.eq(8).text());
        $("#BuMe").val(tds.eq(9).text());
        $("#RenyuanZ").val(tds.eq(10).text());
        $("#JishuTechan").val(tds.eq(11).text());
        document.getElementById("img1").src = tds.eq(13).text();
        
       
    }

    //function Add() {
    //    var Name = $("#Staff_Name").val();
    //    var Age = $("#Staff_Age").val();
    //    var Sex = $("#Staff_Sex").val();
    //    var zhuzhi = $("#Staff_Address").val();
    //    var gongzi = $("#Staff_Money").val();
    //    var gl = $("#Staff_GL").val();
    //    var RzDate = $("#Hiredate").val();
    //    var Peixun = $("#Train").val();
    //    $.ajax({

    //        type: 'post',
    //        url: '/XBK/RenAdd',
    //        data: { Staff_Name: Name, Staff_Age: Age, Staff_Sex: Sex, Staff_Address: zhuzhi, Staff_Money: gongzi, Staff_GL: gl, Hiredate: RzDate, Train: Peixun },

    //        success: function (obj)
    //        {
    //            if (obj > 0) {
    //                alert("添加成功");
    //                location.href = '/Home/Renyuandangan';
    //            }
    //            else {
    //                alert("添加失败");
    //            }
    //        }

    //    })

    //}
    function show() {

        var file = document.getElementById("f").files[0];

        var fileReader = new FileReader();

        fileReader.readAsDataURL(file);

        fileReader.onload = function () {

            document.getElementById("img").src = fileReader.result;

        }

    }
    function show1() {

        var file = document.getElementById("f1").files[0];

        var fileReader = new FileReader();

        fileReader.readAsDataURL(file);

        fileReader.onload = function () {

            document.getElementById("img1").src = fileReader.result;

        }

    }
</script>
